/**
 * Created by zongjuan.wang on 2016/6/30.
 */

$(document).ready(function(){
    $(".bbs header span").click(function(){
        $(".bbs .post").show();
    });
    var tou=new Array("tou01.jpg","tou02.jpg","tou03.jpg","tou04.jpg");
    $(".post .btn").click(function(){
        var $li=$("<li></li>");
        var $newLi=$("<li></li>");
        var iNum=Math.floor(Math.random()*4);
        var $touDiv=$("<div></div>");
        var $touImg=$("<img>");
        $touImg.attr("src","images/"+tou[iNum]);
        $touDiv.append(touImg);

        var $titleH1=$("h1");
        var title=$("#title").val();
        $titleH1.html(title);

        var newp=$("p");
        var $secName=$("<span></span>")
        var secSelect=$("#sec").val();
        $newP.html("板块："+secSelect);
        var myDate=new Date();
        var currentDate=myDate.getFullYear()+"-"+parseInt(myDate.getMinutes(),myDate.getHours(),myDate.getDay(),myDate.getMonth());
        var $timeSpan=$("<span></span>");
        $timeSpan.html("发表时间："+currentDate);
        $newP.append($secName);
        $newP.append($timeSpan)
        $newLi.append($touDiv);
        $newLi.append($touImg);

        var postList=$("#postList");
        postList.prepend($newLi);
        document.getElementById("title").value="";
        document.getElementById("content").value="";
        document.getElementById("post").style.display="none";

    });
})